package sensor;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class SoilSensor extends Sensor {
    private double humidity;
    private double phValue;
    private double nutrientContent;
    private final Random random = new Random();

    public SoilSensor() {
        this.humidity = 20 + random.nextDouble() * 10;
        this.phValue = 6 + random.nextDouble() * 2;
        this.nutrientContent = 30 + random.nextDouble() * 20;
    }


    @Override
    public void notifyObservers(double data) {
        humidity = 20 + random.nextDouble() * 10;
        phValue = 6 + random.nextDouble() * 2;
        nutrientContent = 30 + random.nextDouble() * 20;
        notifyObservers("土壤湿度: " + humidity + ", pH值: " + phValue + ", 养分含量: " + nutrientContent);
    }
}
